package WaiBao;

import java.util.Arrays;

public class HuangYaRu {
    public static void main(String[] args) {
        String[] name = {"张浩成(班长)", "李天乐(副班长)", "小李(学习委员)", "王志阳(体育委员)", "王坤", "张天祥", "李子坝", "张富贵", "王贵才", "张亚星", "李亚伟", "张家口",
                "王博艺", "王乃至", "李到户", "李中南", "林俊杰", "领翔", "李云佳", "王志文", "王劲松", "小猫咪", "柴犬", "柯基", "二哈", "王大嘴", "李大个", "王翔",
                "王多鱼", "皇亚茹(学生)"};//考生本人:皇亚茹(学生)
        int[] age = {20, 21, 19, 20, 21, 22, 21, 21, 19, 19, 18, 18, 18, 21, 20, 19, 19, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 21, 20, 20};//最后一位考生年龄：20岁

        double[] leisheng1 = {80, 84, 84, 85, 78, 69, 78, 89, 80, 91, 90, 87, 85, 74, 75, 78, 69, 99, 96, 88, 92, 91, 95, 88, 75, 74, 78, 74, 85, 96};
        double[] leisheng2 = {77, 74, 74, 88, 85, 76, 84, 79, 71, 80, 84, 78, 87, 77, 65, 65, 70, 74, 76, 68, 92, 71, 95, 81, 75, 84, 74, 94, 94, 96};
        double[] leisheng3 = {76, 90, 71, 85, 71, 69, 78, 80, 80, 69, 93, 87, 85, 75, 64, 68, 69, 69, 96, 93, 92, 81, 95, 95, 79, 84, 75, 71, 84, 95};

        double daer1;//代表每个学生的总分
        double daer2;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            daer1 = leisheng1[i] +leisheng2[i] +leisheng3[i];
//            daer2 = ( daer1* 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + daer1);
//            System.out.println(name[i] + "的平均分为:" +daer2);
//        }


        double keshi1 = 0, keshi2 = 0;
        double[] jiuzhang = new double[30];
//        for (int i = 0; i < 30; i++) {
//            keshi1 = leisheng1[i] + leisheng2[i] +leisheng3[i];
//            keshi2 = (keshi1 * 1.0) / 3;
//            jiuzhang[i] = keshi2;
//        }
//
//        for (int i = 0; i <jiuzhang.length - 1; i++) {
//            for (int j = 0; j < jiuzhang.length - i - 1; j++) {
//                if (jiuzhang[j] < jiuzhang[j + 1]) {
//                    double tep = jiuzhang[j];
//                    jiuzhang[j] = jiuzhang[j + 1];
//                    jiuzhang[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println(jiuzhang[i]);
//        }

        double titok1 = 0,titok2 = 0, titok3 = 0;//计算每门课的平均分
        double side1 = 0,side2 = 0, side3 = 0;//计算每门课标准差
        double doub1 = 0, doub2 = 0, doub3 = 0;//计算每门课中位数
        double sum2 = 0;
        for (int i = 0; i <leisheng1.length; i++) {
            sum2+=leisheng1[i];
        }
        titok1 = (sum2*1.0)/30;
        System.out.println("生物化学的班级平均分为:"+titok1);
        double Sum = 0;
        for (int i = 0; i <leisheng2.length; i++) {
            Sum+=leisheng2[i];
        }
        titok2 = (Sum*1.0)/30;
        System.out.println("微生物学的班级平均分为:"+titok2);
        double sum = 0;
        for (int i = 0; i <leisheng3.length; i++) {
            sum+=leisheng3[i];
        }
        titok3 = (sum*1.0)/30;
        System.out.println("人体组织解剖学的班级平均分为:"+titok3);



        double c1 = 0,c2 = 0,c3 = 0;
        for (int i = 0; i <leisheng1.length; i++) {
            c1+= (leisheng1[i] -titok1)*(leisheng1[i] -titok1);
        }
        side1 = Math.sqrt(c1*1.0/30);
        System.out.println("生物化学的班级标准差为:"+side1);

        for (int i = 0; i < leisheng2.length; i++) {
            c2+= (leisheng2[i] -titok2)*(leisheng2[i] - titok2);
        }
        side2 = Math.sqrt(c2*1.0/30);
        System.out.println("微生物学的班级标准差为:"+side2);

        for (int i = 0; i < leisheng3.length; i++) {
            c3+= (leisheng3[i] -titok3)*(leisheng3[i] - titok3);
        }
        side3 = Math.sqrt(c3*1.0/30);
        System.out.println("人体组织解剖学的班级标准差为:"+side3);
////////
////////
        Arrays.sort(leisheng1);
        Arrays.sort(leisheng2);
        Arrays.sort(leisheng3);
        doub1 =(leisheng1[14]+leisheng1[15])*1.0/2;
        doub2 =( leisheng2[14]+leisheng2[15])*1.0/2;
        doub3 =( leisheng3[14]+leisheng3[15])*1.0/2;
        System.out.println("生物化学的中位数为:"+doub1);
        System.out.println("微生物学的中位数为:"+doub2);
        System.out.println("人体组织解剖学的中位数为:"+doub3);




    }
}
